package cn.fl.fgi.controller;

import cmm.comm.facade.framework.api.ISysDictionaryApiService;
import cmm.comm.facade.upload.api.IUploadApiService;
import cmm.comm.facade.upload.condition.SysUlDatCfgQueryCondition;
import cmm.comm.facade.upload.constant.SysUlFilesRecConstant;
import cmm.comm.facade.upload.dto.SysUlDatCfgDTO;
import cmm.comm.facade.upload.dto.SysUlDatCfgDtlDTO;
import cmm.mid.core.framework.page.DataResultVO;
import cmm.mid.core.framework.page.ListPageVO;
import cmm.web.core.framework.controller.BaseController;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.logger.eum.LogExceptionEnum;
import cn.cmm.base.framework.logger.eum.LogOperEnum;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.DateUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.cmm.cache.framework.service.ICacheService;
import cn.fl.fgi.api.IFgiUpDataApiService;
import cn.fl.fgi.api.IFgiUpDetailApiService;
import cn.fl.fgi.api.condition.FgiUpDataQueryCondition;
import cn.fl.fgi.api.dto.FgiUpDataDTO;
import cn.fl.fgi.api.dto.FgiUpDetailDTO;
import cn.fl.fgi.transform.FgiUpDataVOTransForm;
import cn.fl.fgi.transform.FgiUpDetailVOTransform;
import cn.fl.fgi.util.ImportFgiDataList;
import cn.fl.fgi.vo.FgiUpDataVO;
import cn.fl.fgi.vo.FgiUpDetailVO;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.splrate.service.IParseTempFileRecService;
import cn.fl.splrate.vo.ParseTempFileRecVO;
import cn.fl.system.constant.SysLogConstant;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import fl.constant.facade.framework.constant.BusinessIdConstant;
import fl.spl.facade.framework.constant.SplSystemConstant;
import fl.spl.facade.framework.enums.SplInfoFileCfgEnum;
import net.sf.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @Description: 解析模板文件记录表 控制层
 */
@Controller
@RequestMapping("/fgi/parsetempfilerec")
public class FgiParseTempFileRecController extends BaseController {

    /**
     * ParseTempFileRec 服务层BEAN
     */
    @Autowired
    private IParseTempFileRecService parseTempFileRecService;

    @Autowired
    private ISysDictionaryApiService sysDictionaryApiService;

    @Autowired
    private IUploadApiService uploadApiService;

    @Autowired
    private IFgiUpDetailApiService fgiUpDetailApiService ;

    @Autowired
    private IFgiUpDataApiService fgiUpDataApiService ;

    @Autowired
    private ICacheService cacheService;


    private Lock lock = new ReentrantLock();

    /**
     * 到列表页面
     */
    @RequestMapping(value = "/toListPage.do", method = {RequestMethod.GET})
    public ModelAndView toListPage(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView view = null ;
        view = new ModelAndView("fgi/fgiParseTempFileRecList");
        BaseLogUtils.newWebLogger("加载列表页面").setLogOperType(LogOperEnum.REQ)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                .setWarning(false)
                .info();
        view.addObject("upLoadCode", SplInfoFileCfgEnum.PRJ033.getCode());
        view.addObject("modulePath", SplInfoFileCfgEnum.PRJ033.getModulePath());
        view.addObject("uploadSysCd", SplInfoFileCfgEnum.PRJ033.getUploadSysCd());
        view.addObject("costomerPath", SplInfoFileCfgEnum.PRJ033.getUploadCostomerPath());
        view.addObject("rootPath", SplInfoFileCfgEnum.PRJ033.getUploadRootPath());
        return view;
    }

    /**
     * 到新增修改页面
     */
    @RequestMapping(value = "/toAddPage.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView toAddPage(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView view = new ModelAndView("splrate/parseTempFileRec/parseTempFileRecAdd");

        return view;
    }

    /**
     * 到修改页面
     */
    @RequestMapping(value = "/toModifyPage.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView toModifyPage(HttpServletRequest request, HttpServletResponse response) {

        String id = request.getParameter("id");
        ModelAndView view = new ModelAndView("splrate/parseTempFileRec/parseTempFileRecModify");
        view.addObject("id", id);
        return view;
    }

    /**
     * 到详情页面
     */
    @RequestMapping(value = "/toDetailPage.do", method = {RequestMethod.GET})
    public ModelAndView toDetailPage(HttpServletRequest request, HttpServletResponse response) {

        String id = request.getParameter("id");
        ModelAndView view = new ModelAndView("splrate/parseTempFileRec/parseTempFileRecDetail");
        view.addObject("id", id);

        return view;
    }

    /**
     * 初始化列表
     */
    @SuppressWarnings("unchecked")
    @RequestMapping(value = "/initList.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object initList(HttpServletRequest request, HttpServletResponse response) {


        String currentPage = request.getParameter("page");
        String page = request.getParameter("pagesize");
        String fileNm = request.getParameter("fileNm");
        String crtTmStarStr = request.getParameter("crtTmStar");
        String crtTmEndStr = request.getParameter("crtTmEnd");
        FgiUpDataQueryCondition condition = new FgiUpDataQueryCondition();
        Integer pageNum = 1 ;
        Integer pageSize = 10 ;
        if(StringUtils.isNotEmpty(currentPage)){
            pageNum = Integer.valueOf(currentPage);
        }
        if(StringUtils.isNotEmpty(page)){
            pageSize = Integer.valueOf(page);
        }
        if(StringUtils.isNotEmpty(fileNm)){
            condition.setFileNm(fileNm);
        }
        if(StringUtils.isNotEmpty(crtTmStarStr)){
            condition.setCrtTmMin(DateUtils.formatStringToDate(crtTmStarStr,DateUtils.YYYY_MM_DD));
        }
        if(StringUtils.isNotEmpty(crtTmEndStr)){
            condition.setCrtTmMax(DateUtils.formatStringToDate(crtTmEndStr,DateUtils.YYYY_MM_DD));
        }

        Integer total = 0 ;
        List<FgiUpDataDTO> dtoList = null ;
        String dataString = this.fgiUpDataApiService.searchListPage(condition, pageNum, pageSize);
        if(StringUtils.isNotEmpty(dataString)) {
            JSONObject obj = JSONObject.parseObject(dataString);
            Object  data = obj.get("dataList");
            if(data != null){
                dtoList = JSON.parseArray(data.toString(),FgiUpDataDTO.class);
            }
            Object o = obj.get("total");
            if (o != null) {
                total = Integer.valueOf(o.toString());
            }
        }
        ListPageVO<FgiUpDataVO> listPage = null;
        listPage = new ListPageVO<FgiUpDataVO>(FgiUpDataVOTransForm.toVOList(dtoList),total);
        BaseLogUtils.newWebLogger("加载列表页面").setLogOperType(LogOperEnum.RESP)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                .setWarning(false)
                .setKeys("listPage", JSON.toJSONString(listPage))
                .info();
        return listPage;
    }

    /**
     * 新增
     */
    @RequestMapping(value = "/add.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object add(HttpServletRequest request, HttpServletResponse response) throws BaseException {

        String name = request.getParameter("name");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "新增成功!");
        ParseTempFileRecVO entity = null;
        try {
            entity = new ParseTempFileRecVO();
            //TODO ADD PARAM
            Long id = this.parseTempFileRecService.add(entity);
            result.setData(id);
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("系统错误,请联系管理员!");
        }

        return result;
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/modify.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object modify(HttpServletRequest request, HttpServletResponse response) throws BaseException {

        String id = request.getParameter("id");
        String name = request.getParameter("name");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "修改成功!");
        if (StringUtils.isEmpty(id)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("数据不存在!");
            return result;
        }
        ParseTempFileRecVO entity = null;
        try {
            entity = new ParseTempFileRecVO();
            entity.setId(Long.valueOf(id));
            //entity.setName(name);
            //TODO ADD PARAM
            boolean success = this.parseTempFileRecService.modify(entity);
            if (!success) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo("修改失败!");
            }
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("系统错误,请联系管理员!");
        }

        return result;
    }

    /**
     * 删除数据
     */
    @RequestMapping(value = "/removeById.do", method = {RequestMethod.POST})
    @ResponseBody
    public DataResultVO removeById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        String id = request.getParameter("id");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "删除成功!");
        if (StringUtils.isEmpty(id)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("主键不能为空!");
            return result;
        }
        try {
            this.parseTempFileRecService.removeById(Long.valueOf(id));
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("系统错误,请联系管理员!");
        }

        return result;
    }

    /**
     * 得到一条记录
     *
     * @param request
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getById.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object getById(HttpServletRequest request, HttpServletResponse response) throws BaseException {

        String id = request.getParameter("id");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "操作成功!");
        if (StringUtils.isEmpty(id)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("主键不能为空!");
            return result;
        }

        try {
            ParseTempFileRecVO vo = this.parseTempFileRecService.selectById(Long.valueOf(id));
            if (null == vo) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo("数据不存在!");
            }
            result.setData(vo);
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("系统错误,请联系管理员!");
        }

        return result;
    }

    /***********************
     * 融担详细信息导入
     ***********************/
    @RequestMapping(value = "/toImportFgiData.do", method = {RequestMethod.POST})
    @ResponseBody
    public DataResultVO toImportFgiData(HttpServletRequest request, HttpServletResponse response) {
        String methodNm = "toImportFgiData";
        Long beginTimeSign = System.currentTimeMillis();
        BaseLogUtils.newWebLogger("融担数据导入,参数信息").setLogOperType(LogOperEnum.REQ)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                .setWarning(false)
                .setKeys("request", this.getRequestParameter(request))
                .info();
        String upLoadCode = request.getParameter("upLoadCode"); //文件配置CODE
        String filePath = request.getParameter("filePath");//文件路径
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "融担数据导入成功！");

        String bizTypCd = "FGI" ;
        if (StringUtils.isEmpty(upLoadCode) || StringUtils.isEmpty(filePath)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("融担数据解析,因参数不完整导致解析失败!");
            BaseLogUtils.newWebLogger("融担数据解析,因参数不完整导致解析失败").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .warn(LogExceptionEnum.COMMON_CODE_0001);
            return result;
        }
        if (!this.cacheService.keyExists("toImportSplRateData_" + upLoadCode, "remote")) {
            BaseLogUtils.newWebLogger("融担数据导入操作").setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setKeys("upLoadCode", JSON.toJSONString(upLoadCode))
                    .info();
            this.cacheService.add("toImportSplRateData_" + upLoadCode, filePath);
        } else {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("因存在另一个解析任务操作，请稍后再试!");
            BaseLogUtils.newWebLogger("融担数据解析,因存在另一个解析任务而停止解析").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .warn(LogExceptionEnum.COMMON_CODE_0001);
            return result;
        }
        List<ParseTempFileRecVO> parseTempFileRecVOList = null;
        Map<String, String> starLvlCdNmMap = null;
        Map<String, List<FgiUpDetailVO>> stringListMap = null;
        List<List<FgiUpDetailDTO>> lists = null;
        List<FgiUpDetailDTO> fgiUpDetailDTOList = null;
        Long ParseFileRecId = null ;
        try {

            lock.lock();
            //1、查询最新的版本号
/*            ParseTempFileRecQC parseTempFileRecQC = new ParseTempFileRecQC();
            parseTempFileRecQC.setIsDel(BaseConstant.IS_YESNO_NO);
            parseTempFileRecQC.setIsNew(MagicNumReplaceEnum.REP_IGNORE_VAL.getVal());
            parseTempFileRecQC.setIsValid(BaseConstant.IS_YESNO_YES);
        	parseTempFileRecQC.setBizTypCd(bizTypCd);
            parseTempFileRecVOList = this.parseTempFileRecService.searchParseTempFileRecVOList(parseTempFileRecQC);
            String versionNum = null;
            String versionPrex = "V" + DateUtils.formatDateToString(new Date(), DateUtils.YYMMDD) + upLoadCode;
            int verNo = BaseConstant.IS_YESNO_YES;
            if (CollectionUtils.isNotEmpty(parseTempFileRecVOList)) {
                versionNum = parseTempFileRecVOList.get(BaseConstant.IS_YESNO_NO).getVerNum();
                if (StringUtils.isNotEmpty(versionNum)) {
                    //versionNum = "V20191009SPL022_9999";
                    String[] versionSplit = versionNum.split("_");
                    if (versionSplit[BaseConstant.IS_YESNO_NO].equals(versionPrex)) {
                        verNo = Integer.parseInt(versionSplit[BaseConstant.IS_YESNO_YES]) + BaseConstant.IS_YESNO_YES;
                    }
                } else {
                    result.setSuccess(BaseConstant.IS_YESNO_NO);
                    result.setInfo("版本号不存在，请联系管理员！");
                    BaseLogUtils.newWebLogger("融担数据解析,版本号不存在").setLogOperType(LogOperEnum.REQ)
                            .setSysCd(CurrentThreadContext.getCurrentSysCd())
                            .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                            .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                            .setWarning(false)
                            .warn(LogExceptionEnum.COMMON_CODE_0001);
                    return result;
                }
            }
            versionNum = versionPrex + "_" + verNo;
            BaseLogUtils.newWebLogger("融担数据解析,版本号").setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setKeys("versionNum", JSON.toJSONString(versionNum))
                    .info();*/
            //2、保存解析文件的相关信息
            String rootPath = SysUlFilesRecConstant.SYS_FILE_UPLOAD_ROOT_PATH;
            SplInfoFileCfgEnum splInfoFileCfgEnum = SplInfoFileCfgEnum.getEnumByCode(upLoadCode);
            if (StringUtils.isNotEmpty(upLoadCode) && null != splInfoFileCfgEnum) {
                rootPath = SplInfoFileCfgEnum.getEnumByCode(upLoadCode).getUploadRootPath();
            }
            String fileParams = request.getParameter("fileParams"); //附件信息 add by jiangzg 2019-10-08 20:20:19
            //通过主键id 查询已经上传的附件信息 add by jiangzg 2019-10-08 20:20:15
            Long parseTempFileRecId = null;
            if (StringUtils.isNotEmpty(fileParams)) {
                JSONArray arry = JSONArray.fromObject(fileParams);
                if (!(arry.size() > 0)) {
                    result.setSuccess(BaseConstant.IS_YESNO_NO);
                    result.setInfo("融担数据导入因未查询到解析文件而结束");
                    return result;
                } else {
                    //查询资料配置，系统代码,组织架构代码,配置编号 ,业务主键
                    SysUlDatCfgQueryCondition ulDatCfgQueryCondition = new SysUlDatCfgQueryCondition();
                    ulDatCfgQueryCondition.setSysCd(splInfoFileCfgEnum.getSysCd());//系统代码
                    ulDatCfgQueryCondition.setOrgCd(splInfoFileCfgEnum.getOrgCd());
                    ulDatCfgQueryCondition.setIsValid(BaseConstant.IS_YESNO_YES);
                    ulDatCfgQueryCondition.setIsDel(BaseConstant.IS_YESNO_NO);
                    List<String> cfgCdList = new ArrayList<>();
                    cfgCdList.add(upLoadCode);//配置编号
                    ulDatCfgQueryCondition.setCfgCdList(cfgCdList);//配置编号集合
                    List<SysUlDatCfgDTO> list = this.uploadApiService.searchSysUlDatCfgList(ulDatCfgQueryCondition);
                    String cfgDtlCd = null;
                    if (CollectionUtils.isNotEmpty(list)) {
                        SysUlDatCfgDtlDTO sysUlDatCfgDtlDTO = list.get(BaseConstant.IS_YESNO_NO).getSysUlDatCfgDtlDTOList().get(BaseConstant.IS_YESNO_NO);
                        cfgDtlCd = sysUlDatCfgDtlDTO.getCfgDtlCd();
                    }
                    //解析附件上传信息
                    if (StringUtils.isNotEmpty(fileParams)) {
                        List<Map<String, String>> fileParamsList = new ArrayList<Map<String, String>>();
                        for (int i = 0; i < arry.size(); i++) {
                            net.sf.json.JSONObject jsonObject = arry.getJSONObject(i);
                            Iterator<?> it = jsonObject.keys();
                            HashMap<String, String> hMap = new HashMap<String, String>();
                            while (it.hasNext()) {
                                String key = String.valueOf(it.next());
                                String value = (String) jsonObject.get(key);
                                hMap.put(key, value);
                            }
                            fileParamsList.add(hMap);
                        }
                        Map<String, String> map = fileParamsList.get(BaseConstant.IS_YESNO_NO);
                        FgiUpDataVO fgiUpDataVO = new FgiUpDataVO();
                        fgiUpDataVO.setFileNm(map.get("fileNm"));
                        fgiUpDataVO.setCrtTm(new Date());
                        fgiUpDataVO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
                        fgiUpDataVO.setCrtUsrNm(CurrentThreadContext.getCurrentUserName());
                        fgiUpDataVO.setDataStatus(2);
                        ParseFileRecId = this.fgiUpDataApiService.save(FgiUpDataVOTransForm.toDTO(fgiUpDataVO)) ;

                    } else {
                        throw new BaseException(BaseExceptionConstant.COMMON_0001, "没有要解析的资料.");
                    }
                }
            }
            //3、解析文件
            stringListMap = ImportFgiDataList.importFgiInportDataVOXls(rootPath, filePath, starLvlCdNmMap, ParseFileRecId);
            if (CollectionUtils.isMapNotEmpty(stringListMap)) {
                for (Map.Entry<String, List<FgiUpDetailVO>> entry : stringListMap.entrySet()) {
                    int len = entry.getValue().size() % 2000 == 0 ? entry.getValue().size() / 2000 : entry.getValue().size() / 2000 + 1;
                    lists = new ArrayList<>(len);
                    int i = 0;
                    for (FgiUpDetailVO vo : entry.getValue()) {
                        ++i;
                        vo.setFgiUpDataId(ParseFileRecId);
                        if (fgiUpDetailDTOList == null) {
                            fgiUpDetailDTOList = new ArrayList<>();
                        }
                        vo.setCrtTm(new Date());
                        fgiUpDetailDTOList.add(FgiUpDetailVOTransform.toDTO(vo));
                       /* if (i % 2000 == 0 || i == entry.getValue().size()) {
                            lists.add(fgiUpDetailDTOList);
                            fgiUpDetailDTOList = null;
                        }*/
                    }
                    //4、批量插入经销商/挂靠公司评分数据
                    String rpcSign = parseTempFileRecId + "_" + CurrentThreadContext.getCurrentUserId() + "_" + CurrentThreadContext.getCurrentUserName();
                    BaseLogUtils.newWebLogger("融担数据导入，调用batchAddAndMdfSplRateRelData唯一标识[" + rpcSign + "]").setLogOperType(LogOperEnum.RESP)
                            .setSysCd(CurrentThreadContext.getCurrentSysCd())
                            .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                            .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                            .setWarning(false)
                            .setKeys("starLvlCdNmMap", JSON.toJSONString(starLvlCdNmMap))
                            .info();
                    //DataResultDTO dataResultDTO = this.splRelInfoForInnerApiService.batchAddAndMdfSplRateRelData(lists, entry.getKey(), parseTempFileRecId,bizTypCd, CurrentThreadContext.getCurrentUserId(), SplSystemConstant.FL_WEB_CHL_CD, null, rpcSign);
                    boolean b = fgiUpDetailApiService.saveBatch(fgiUpDetailDTOList) ;
                }
            } else {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
                BaseLogUtils.newWebLogger("融担数据导入,导入数据为空").setLogOperType(LogOperEnum.REQ)
                        .setSysCd(CurrentThreadContext.getCurrentSysCd())
                        .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                        .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                        .setWarning(false)
                        .warn(LogExceptionEnum.COMMON_CODE_0001);
            }
        } catch (Exception e) {
            BaseLogUtils.newWebLogger("融担数据导入异常,系统异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(e)
                    .error(LogExceptionEnum.COMMON_CODE_0099);
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(e.getMessage());
        } finally {
            lock.unlock();
            if (this.cacheService.keyExists("toImportSplRateData_" + upLoadCode)) {
                this.cacheService.delete("toImportSplRateData_" + upLoadCode);
            }
            parseTempFileRecVOList = null;
            starLvlCdNmMap = null;
            stringListMap = null;
            lists = null;
            fgiUpDetailDTOList = null;
        }
        return result;
    }
}

